package com.jinke.api.modules.third.shipber.model.response;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jinke.api.common.api.CommonResult;
import lombok.Data;

@Data
public class CreateOrderResponse {

    private DataT data;

    private String message;

    private boolean success = true;
    @Data
    public static class DataT {
        private String status;
        @JsonProperty("tracking_num")
        private String trackingNum;
        @JsonProperty("order_num")
        private String orderNum;
        private Shipment shipment;

        // Getters and setters
    }
    @Data
    public static class Shipment {
        @JsonProperty("label_download")
        private LabelDownload labelDownload;
        private Charge charge;
    }
    @Data
    public static class LabelDownload {
        private String pdf;
    }
    @Data
    public static class Charge {
        private String code;
        private Double value;

        // Getters and setters
    }

    public CommonResult toCommonResult() {
        // 判断是否成功
        CommonResult commonResult = CommonResult.success();
        if (StringUtils.isNotBlank(message)) {
            commonResult = CommonResult.failed(message);
            success = false;
        }

        return commonResult;
    }
}
